package com.lzy.product.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lzy.framework.core.orm.db.Pager;
import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.AgentCommissionBillMapperExt;
import com.lzy.product.dtos.agent.AgentBillScreenListDto;
import com.lzy.product.dtos.agent.AgentCommissionBillDto;
import com.lzy.product.dtos.agent.AgentCommissionBilltStatisticsDto;
import com.lzy.product.entity.AgentCommissionBill;
import com.lzy.product.service.AgentCommissionBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class AgentCommissionBillServiceImpl implements AgentCommissionBillService {

    @Autowired
    private AgentCommissionBillMapperExt agentCommissionBillMapperExt;


    @Override
    public Long insert(AgentCommissionBillDto dto) {
        AgentCommissionBill agentCommissionBill = DozerUtils.map(dto, AgentCommissionBill.class);
        return agentCommissionBillMapperExt.insertSelective(agentCommissionBill) > 0 ? agentCommissionBill.getId() : 0;
    }

    @Override
    public Boolean update(AgentCommissionBillDto dto) {
        return agentCommissionBillMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto, AgentCommissionBill.class)) > 0;
    }

    @Override
    public Boolean delete(Long id) {
        return null;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public AgentCommissionBillDto findById(Long id) {
        return DozerUtils.map(agentCommissionBillMapperExt.selectByPrimaryKey(id), AgentCommissionBillDto.class);
    }

    @Override
    public List<AgentCommissionBillDto> query(AgentCommissionBillDto dto) {
        return null;
    }

    @Override
    public PageInfo<AgentCommissionBillDto> selectList(Pager pager, AgentCommissionBillDto dto) {
        if (pager != null)
            PageHelper.startPage(pager.getPageNum(), pager.getPageSize());
        List<AgentCommissionBillDto> list = agentCommissionBillMapperExt.selectList(dto);
        return new PageInfo<>(list);
    }

    @Override
    public List<AgentCommissionBilltStatisticsDto> statisticsBillForMonth() {
        return agentCommissionBillMapperExt.statisticsBillForMonth();
    }

    @Override
    public List<AgentCommissionBilltStatisticsDto> statisticsBillForDay() {
        return agentCommissionBillMapperExt.statisticsBillForDay();
    }

    @Override
    public AgentCommissionBilltStatisticsDto statisticsBill() {
        return agentCommissionBillMapperExt.statisticsBill();
    }

    @Override
    public BigDecimal getCommAmount(AgentCommissionBillDto dto) {
        return agentCommissionBillMapperExt.getCommAmount(dto);
    }

    @Override
    public List<AgentBillScreenListDto> selectScreenList(Integer type) {
        return agentCommissionBillMapperExt.selectScreenList(type);
    }

    @Override
    public List<AgentBillScreenListDto> selectSystemList(Long sourceId,Integer type) {
        return agentCommissionBillMapperExt.selectSystemList(sourceId,type);
    }

}
